package com.zc.mall.controller;

import com.github.pagehelper.PageInfo;
import com.zc.mall.service.IProductService;
import com.zc.mall.vo.ProductDetailVo;
import com.zc.mall.vo.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 曾川
 * @version 1.0.0
 * @ClassName ProductController.java
 * @Description 商品Controller
 * @createTime 2021年06月07日 17:33:00
 */
@RestController
public class ProductController {

    @Autowired
    private IProductService productService;

    @GetMapping("/products")
    public ResponseVo<PageInfo> list(@RequestParam( required = false) Integer categoryId,
                                     @RequestParam( required = false,defaultValue = "1")Integer pageNum,
                                     @RequestParam( required = false,defaultValue = "10")Integer pageSize) {
        return productService.list(categoryId, pageNum, pageSize);
    }

    @GetMapping("/product/{productId}")
    public ResponseVo<ProductDetailVo> detail(@PathVariable Integer productId) {
        return productService.deatil(productId);
    }


}
